package dao;


import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import po.User;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Administrator on 2017/12/20.
 */
public class UserDaoImpl implements UserDao {
    SqlSessionFactory factory ;

    public UserDaoImpl(SqlSessionFactory factory) {
        this.factory = factory;
    }

    public User finduserById(int id) throws IOException {

          /*读文件 生成工厂
          工厂生成会话
          会话执行语句
          关闭会话
          * */

        SqlSession sqlSession = factory.openSession();
        User user = sqlSession.selectOne("findUserById",id);
        return user;
    }
}
